package day_11;

import java.util.Scanner;
import java.util.Stack;

public class ques2 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int a = in.nextInt();
            if(a==1){
                System.out.println(1);
                return;
            }
            int oneMax=0;
            //boolean flag=true;
            Stack<Integer> stack=new Stack<>();
            stack.push(0);
            while(a!=0){
                //boolean flag=true;
                int index=a&1;
                if(index==1){
                    oneMax++;
                }
                if(oneMax>stack.peek()){
                    stack.pop();
                    stack.push(oneMax);
                    //flag=false;
                }
                if(index==0){
                    oneMax=0;
                }
                //    if(flag){
                //      oneMax=0;
                //    }
                a=a>>1;
            }



            System.out.println(stack.peek());
        }
    }

}
